﻿//
//  EntryState
//
//  Created by Codyo on 2008-07-05.
//  Copyright (c) 2008 Codyo. All rights reserved.
//

import com.codyo.mobileStateMachine.MobileStateMachine;
import com.codyo.mobileStateMachine.AbstractState;
import com.codyo.data.dummyData 
//import com.codyo.data.ProblemSet;

class com.codyo.states.GameInitState extends AbstractState{
	
	private var stateMachine:MobileStateMachine;
	
	private var theStage:MovieClip;
	private var change_interval:Number;
	
	function GameInitState(stateMachine:MobileStateMachine){
		this.stateMachine = stateMachine;
		
		trace("Game Init state entered");
		init();
	}
	
	public function keypadPressed(theKey:String):Void{
		theStage = this.stateMachine.getStage();	//need to move this
		init();
		switch(theKey){
			
			default:
				trace("GAME INIT STATE - key press not assigned");
				theStage.readout_txt.text = "GAME INIT STATE - key not assigned pressed: "+theKey;
				break;
			
		}
	}
	
	private function init():Void{
		//parse dummy data
		dummyData(); 
		//should parse data here but using a shortcut right now to go to the game play state
		change_interval = setInterval(this, "dataLoaded", 1500);
	}
	
	private function dataLoaded():Void{
		clearInterval(change_interval);
		stateMachine.setState(MobileStateMachine.GAME_PLAY_STATE);
	}
}